package demo10;

public class Test {
    public static void main(String[] args)
            throws CloneNotSupportedException{
        Person person1 = new Person("小明",18);
        Person person2 = (Person) person1.clone();

        System.out.println("修改前"+person1.i.id);
        System.out.println("修改前"+person2.i.id);
        person2.i.id = 224455;
        System.out.println("修改后"+person1.i.id);
        System.out.println("修改后"+person2.i.id);
    }
    public static void main1(String[] args) throws CloneNotSupportedException{
        Person person1 = new Person("李明", 25);
        //使用clone进行对象的拷贝
        Person person2 = (Person)person1.clone();
    }
}
